<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org/">
<head>
<meta charset="UTF-8">
<title>订单管理</title>
<script type="text/javascript" th:src="@{/bootstrap3/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/npm.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/popper.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap-popover.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery.dropdown.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap-theme.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap-theme.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap.min.css}" />
</head>
<script type="text/javascript">
	function querybtnmuti(){
		var status = $("#status").val();
		var phone = $("#phone").val();
		var pattern = /^[1]{1}[0-9]{10}$/;
		if(phone!=""){
			if(!pattern.test(phone)){
				window.alert("手机号错误！");
			}
		}
		$.ajax({
			type:"post",
			url:"querybtnmuti",
			async:true,
			data:{status:status,phone:phone},
			dataType:"json",
			success:function(data){
				var content = "";
				for(var i=0;i<data.length;i++){
					content += '<tr>'+
						'<td>'+data[i].subscription.id+'</td>'+
						'<td>'+data[i].subscription.no+'</td>'+
						'<td>'+data[i].room.no+'</td>'+
						'<td>'+data[i].subscription.linkman+'</td>'+
						'<td>'+data[i].subscription.email+'</td>'+
						'<td>'+data[i].subscription.phone+'</td>'+
						'<td>'+data[i].subscription.cretime+'</td>'+
						'<td>'+data[i].subscription_dtl.sdate+'</td>'+
						'<td>'+data[i].subscription_dtl.edate+'</td>'+
						'<td><a href="javascript:void(0)" class="btn btn-warning btn-sm" onclick="confirmsub(\''+data[i].subscription.no+'\')">确认</a></td>'+
					'</tr>';
				}
				document.getElementById("table_bodytip").innerHTML = content;
			},
			error:function(){
				window.alert("内部故障，请联系管理员！");
			}
		});
	}
	function confirmsub(no){
		$.ajax({
			type:"post",
			url:"updatestatus?no="+no,
			async:true,
			data:{},
			dataType:"json",
			success:function(data){
				if(data==1){
					window.alert("确认成功！");
				}else{
					window.alert("失败");
				}
				$("#admin_main_content").load("queryMuti");
			},
			error:function(){
				window.alert("程序故障");
			}
		});
	}
</script>
<body>
<div class="container-fluid">
	<div class="panel panel-default">
		<div class="panel-heading">
			<div class="container">
				<div class="row">
					<div class="col-sm-3"></div>
					<div class="col-sm-3">
						<label style="float: left;">确认状态:</label>
						<select style="width: 120px;height: 28px;" id="status" class="form-control">
							<option value="c">已确认</option>
							<option value="m">未确认</option>
						</select>
					</div>
					<div class="col-sm-4">
						<label style="float: left;">电话号码:</label>
						<input style="width: 180px;height: 27px;" id="phone" type="text" class="form-control" maxlength="11">
					</div>
					<div id="col-sm-3" class="text-left">
						<a href="javascript:void(0)" onclick="querybtnmuti()" class="btn btn-info btn-xs">查询</a>
					</div>
				</div>
			</div>
		</div>
		<div class="panel-body" style="height: 450px;overflow: auto;">
			<table class="table table-responsive">
				<thead>
					<tr>
						<th>序号</th>
						<th>订单号</th>
						<th>房间号</th>
						<th>联系人</th>
						<th>邮箱</th>
						<th>电话</th>
						<th>创建时间</th>
						<th>开始时间</th>
						<th>结束时间</th>
						<th>确认</th>
					</tr>
				</thead>
				<tbody id="table_bodytip">
					<tr th:each="historysub,historySta:${category_Room_SubDtls}">
						<td th:text="${historysub.subscription.id}"></td>
						<td th:text="${historysub.subscription.no}"></td>
						<td th:text="${historysub.room.no}"></td>
						<td th:text="${historysub.subscription.linkman}"></td>
						<td th:text="${historysub.subscription.email}"></td>
						<td th:text="${historysub.subscription.phone}"></td>
						<td th:text="${#dates.format(historysub.subscription.cretime, 'yyyy-MM-dd HH:mm:ss')}"></td>
						<td th:text="${#dates.format(historysub.subscription_dtl.sdate, 'yyyy-MM-dd HH:mm:ss')}"></td>
						<td th:text="${#dates.format(historysub.subscription_dtl.sdate, 'yyyy-MM-dd HH:mm:ss')}"></td>
						<td><a href="javascript:void(0)" class="btn btn-warning btn-sm" th:onclick="confirmsub([[${historysub.subscription.no}]])">确认</a></td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>
</body>
</html>
